package com.star.blog.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 后端给前端返回的统一格式的数据
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private boolean success;  //是否成功

    private int code;   //码

    private String msg;  //信息

    private Object data; //数据

    public static Result success(Object data){
        return new Result(true,200,"success",data);
    }

    public static Result fail(int code, String msg){
        return new Result(false,code,msg,null);
    }
}
